﻿using System.Collections.Generic;


/*===================================================
* 类名称: Role
* 类描述:
* 创建人: Sc
* 创建时间: 2019/8/30 22:45:11
* 修改人: 
* 修改时间:
* 版本： @version 1.0
=====================================================*/
namespace OrderSystem.Common
{
    public class Role
    {
        private int _nRroleID = -1;

        private string _sRoleName = null;

        private IList<PowerItem> _list = new List<PowerItem>();

        public bool this[PowerName ePowerName]
        {
            get
            {
                //return true;

                bool result = false;
                for (int i = 0; i < this._list.Count; i++)
                {
                    if (this._list[i].Name == ePowerName)
                    {
                        result = true;
                        break;
                    }
                }
                return result;
            }
        }

        public int RoleID
        {
            get
            {
                return this._nRroleID;
            }
            set
            {
                this._nRroleID = value;
            }
        }

        public string RoleName
        {
            get
            {
                return this._sRoleName;
            }
            set
            {
                this._sRoleName = value;
            }
        }

        public IList<PowerItem> PowerList
        {
            get
            {
                return this._list;
            }
        }

        public void AddPowerItem(PowerItem powerItem)
        {
            this._list.Add(powerItem);
        }

        public static PowerName GetPowerName(string sPowerName)
        {
            PowerName result;
            if (sPowerName == PowerName.Coustomer_Create.ToString())
            {
                result = PowerName.Coustomer_Create;
            }
            else if (sPowerName == PowerName.Coustomer_Delete.ToString())
            {
                result = PowerName.Coustomer_Delete;
            }
            else if (sPowerName == PowerName.Coustomer_Update.ToString())
            {
                result = PowerName.Coustomer_Update;
            }
            else if (sPowerName == PowerName.Coustomer_See.ToString())
            {
                result = PowerName.Coustomer_See;
            }
            else if (sPowerName == PowerName.Project_Create.ToString())
            {
                result = PowerName.Project_Create;
            }
            else if (sPowerName == PowerName.Project_Delete.ToString())
            {
                result = PowerName.Project_Delete;
            }
            else if (sPowerName == PowerName.Project_Update.ToString())
            {
                result = PowerName.Project_Update;
            }
            else if (sPowerName == PowerName.Project_See.ToString())
            {
                result = PowerName.Project_See;
            }
            else if (sPowerName == PowerName.Order_Create.ToString())
            {
                result = PowerName.Order_Create;
            }
            else if (sPowerName == PowerName.Order_Delete.ToString())
            {
                result = PowerName.Order_Delete;
            }
            else if (sPowerName == PowerName.Order_Update.ToString())
            {
                result = PowerName.Order_Update;
            }
            else if (sPowerName == PowerName.Order_See.ToString())
            {
                result = PowerName.Order_See;
            }
            else if (sPowerName == PowerName.Order_Edited.ToString())
            {
                result = PowerName.Order_Edited;
            }
            else if (sPowerName == PowerName.Order_UnEdited.ToString())
            {
                result = PowerName.Order_UnEdited;
            }
            else if (sPowerName == PowerName.Order_Lock.ToString())
            {
                result = PowerName.Order_Lock;
            }
            else if (sPowerName == PowerName.Order_UnLock.ToString())
            {
                result = PowerName.Order_UnLock;
            }
            else if (sPowerName == PowerName.Order_Print.ToString())
            {
                result = PowerName.Order_Print;
            }
            else if (sPowerName == PowerName.Order_PrintLabel.ToString())
            {
                result = PowerName.Order_PrintLabel;
            }
            else if (sPowerName == PowerName.Order_Cancel.ToString())
            {
                result = PowerName.Order_Cancel;
            }
            else if (sPowerName == PowerName.Order_Activate.ToString())
            {
                result = PowerName.Order_Activate;
            }
            else if (sPowerName == PowerName.Order_Payed.ToString())
            {
                result = PowerName.Order_Payed;
            }
            else if (sPowerName == PowerName.Order_NotPayed.ToString())
            {
                result = PowerName.Order_NotPayed;
            }
            else if (sPowerName == PowerName.OrderData_Create.ToString())
            {
                result = PowerName.OrderData_Create;
            }
            else if (sPowerName == PowerName.OrderData_Delete.ToString())
            {
                result = PowerName.OrderData_Delete;
            }
            else if (sPowerName == PowerName.OrderData_Update.ToString())
            {
                result = PowerName.OrderData_Update;
            }
            else if (sPowerName == PowerName.OrderData_See.ToString())
            {
                result = PowerName.OrderData_See;
            }
            else if (sPowerName == PowerName.OrderData_SeePrice.ToString())
            {
                result = PowerName.OrderData_SeePrice;
            }
            else if (sPowerName == PowerName.Invoice_Create.ToString())
            {
                result = PowerName.Invoice_Create;
            }
            else if (sPowerName == PowerName.Invoice_Delete.ToString())
            {
                result = PowerName.Invoice_Delete;
            }
            else if (sPowerName == PowerName.Invoice_Update.ToString())
            {
                result = PowerName.Invoice_Update;
            }
            else if (sPowerName == PowerName.Invoice_See.ToString())
            {
                result = PowerName.Invoice_See;
            }
            else if (sPowerName == PowerName.Invoice_Edited.ToString())
            {
                result = PowerName.Invoice_Edited;
            }
            else if (sPowerName == PowerName.Invoice_UnEdited.ToString())
            {
                result = PowerName.Invoice_Edited;
            }
            else if (sPowerName == PowerName.Invoice_Lock.ToString())
            {
                result = PowerName.Invoice_Lock;
            }
            else if (sPowerName == PowerName.Invoice_UnLock.ToString())
            {
                result = PowerName.Invoice_UnLock;
            }
            else if (sPowerName == PowerName.Invoice_Print.ToString())
            {
                result = PowerName.Invoice_Print;
            }
            else if (sPowerName == PowerName.Invoice_PrintLabel.ToString())
            {
                result = PowerName.Invoice_PrintLabel;
            }
            else if (sPowerName == PowerName.Invoice_Cancel.ToString())
            {
                result = PowerName.Invoice_Cancel;
            }
            else if (sPowerName == PowerName.Invoice_Activate.ToString())
            {
                result = PowerName.Invoice_Activate;
            }
            else if (sPowerName == PowerName.Invoice_Payed.ToString())
            {
                result = PowerName.Invoice_Cancel;
            }
            else if (sPowerName == PowerName.Invoice_Payed.ToString())
            {
                result = PowerName.Invoice_Activate;
            }
            else if (sPowerName == PowerName.InvoiceData_Create.ToString())
            {
                result = PowerName.InvoiceData_Create;
            }
            else if (sPowerName == PowerName.InvoiceData_Delete.ToString())
            {
                result = PowerName.InvoiceData_Delete;
            }
            else if (sPowerName == PowerName.InvoiceData_Update.ToString())
            {
                result = PowerName.InvoiceData_Update;
            }
            else if (sPowerName == PowerName.InvoiceData_See.ToString())
            {
                result = PowerName.InvoiceData_See;
            }
            else if (sPowerName == PowerName.InvoiceData_SeePrice.ToString())
            {
                result = PowerName.InvoiceData_SeePrice;
            }
            else if (sPowerName == PowerName.User_Create.ToString())
            {
                result = PowerName.User_Create;
            }
            else if (sPowerName == PowerName.User_Delete.ToString())
            {
                result = PowerName.User_Delete;
            }
            else if (sPowerName == PowerName.User_Update.ToString())
            {
                result = PowerName.User_Update;
            }
            else if (sPowerName == PowerName.User_See.ToString())
            {
                result = PowerName.User_See;
            }
            else
            {
                result = PowerName.None;
            }
            return result;
        }

        public void Clear()
        {
            this._nRroleID = -1;
            this._sRoleName = null;
            this._list.Clear();
        }
    }
}
